<template>
    <div class="flex align-center justify-center" style="width: 800px;">
        页面暂无素材
        <div style="position: fixed;z-index: 999;background-color: #EBEAEA;
        width: 500px;height: 500px;left: 100px;top: 10px;"
             class="flex flex-column">
            <div style="width:100%;height: 250px;" class="flex">
                <el-image :src="require('../../../assets/img/001.jpg')"
                          style="width:auto;height: 50%;position: absolute;top: 0px;"
                          fit="cover"></el-image>
                <!--<div style="position: relative;top: 180px;margin-left: 20px;margin-right: 20px;" class="flex flex-1">-->
                    <!--<el-image :src="require('../../../assets/img/005.jpg')"-->
                              <!--style="width:120px;height: 120px;border-radius: 50%;"-->
                              <!--fit="cover" class="flex"></el-image>-->


                <!--</div>-->


            </div>
            <div class="flex flex-column" style="width: 100%;padding-left: 20px;padding-right: 20px;">
                <div class="flex align-center justify-between">
                    <span class="flex" style="font-size: 20px;">{{userName}}</span>
                    <div style="cursor: pointer;" @click="changeSupport">
                        <span class="icon iconfont icon-dianzan" style="color: #292B2E;font-size: 20px;"></span>
                        <span>{{support}}</span>
                    </div>

                </div>
            </div>
            <div style="cursor: pointer;font-size: 20px;margin-left: 20px;"
                 class="flex"
                @click="logOut">退出</div>
        </div>
    </div>

</template>

<script>
    export default {
        name: "user",
        data() {
            return {
                userId:-1,
                userName:'',
                nickName:'',
                userLevel:'',
                token:'',
                support:22,
                isSupport:false,
                note: {
                    backgroundImage: "url(" + require("../../../assets/img/login-bg1.jpg") + ")",
                    backgroundSize: "100%",
                    backgroundRepeat: "no-repeat",
                    backgroundPosition: "center center"
                },
                windowHeight:0
            }
        },
        mounted:function(){
            this.windowHeight = document.documentElement.clientHeight;
            // this.windowHeight = window.innerHeight;
            // console.log(this.windowHeight);
            // localStorage.setItem('accessToken', 'Bearer ' + res.data.data.token);
            this.token = localStorage.getItem('accessToken');
            this.userId = localStorage.getItem('userId');
            this.userName = localStorage.getItem('userName');
            this.nickName = localStorage.getItem('nickName');
            this.userLevel = localStorage.getItem('userLevel');
        },
        methods:{
            logOut:function () {

                this.$axios.post('/sevenchat/api/user/v1/logOut',
                    {'code':this.userName, 'userType':this.userLevel},{
                        headers: {
                            // authorization: 'Bearer '+this.token
                            token:this.token
                        }
                    }
                ).then((res)=>{
                    // this.errorCode='';
                    // this.errorMsg = '';
                    console.log(res.data);
                    if(res.data.code=='10000'){
                        localStorage.removeItem('accessToken');
                        localStorage.removeItem('userId');
                        localStorage.removeItem('userName');
                        localStorage.removeItem('nickName');
                        localStorage.removeItem('userLevel');

                        this.$router.push({name:'login'});
                    }

                    // this.$router.push({name:'login'});
                    // if(res.data.code=='10000'){
                    //     localStorage.setItem('accessToken', res.data.data.token);
                    //     localStorage.setItem('userId',  res.data.data.id);
                    //     localStorage.setItem('userName', res.data.data.code);
                    //     localStorage.setItem('nickName', res.data.data.nickname);
                    //     localStorage.setItem('userLevel', res.data.data.userType);
                    //     this.$router.push({name:'msg',
                    //         params:{
                    //             userId:res.data.data.id,
                    //             userName:res.data.data.code,
                    //             nickName:res.data.data.nickname,
                    //             userLevel:res.data.data.userType
                    //         }});
                    // }else{
                    //     this.errorCode=res.data.code;
                    //     this.errorMsg = res.data.message;
                    // }
                }).catch((err)=>{
                    console.error(err);
                });


            },
            changeSupport(){
                this.isSupport = !this.isSupport;
                let url = '';
                if(this.isSupport){
                    this.support++;
                    url = 'praise';
                }else{
                    this.support--;
                    url = 'reduce';
                }
                this.$axios.post('/sevenchat/api/user/v1/'+url,
                    {'code':this.userName, 'userType':this.userLevel},{
                        headers: {
                            token:this.token
                        }
                    }
                ).then((res)=>{
                    // this.errorCode='';
                    // this.errorMsg = '';
                    console.log(res);

                }).catch((err)=>{
                    console.error(err);
                });
            }
        }
    }
</script>

<style scoped>

</style>
